﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using CommerceOne.Common;
using CommerceOne.Domains.Authentication;
using CommerceOne.Domains.SqlRepositories;
using CommerceOne.Models;

namespace CommerceOne.Controllers
{
    public class AddressController : ControllerBase
    {
        [Authorize]
        public ActionResult Index()
        {
            var viewModel = new AddressesViewModel();
            var parameter = new Parameters { PageType = PageType.Address };
            CommonInitialize(viewModel, parameter);

            // Get Address
            CommerceOnePrincipal user = this.CurrentPrincipal;
            if (user == null) throw new Exception("Cannot get logged-in user");
            var currentIdentity = (CommerceOneIdentity ) user.Identity;
            viewModel.Addresses = SqlAddressRepository.Instance.GetByUser(currentIdentity.ID);

            return View(viewModel);
        }

        [HttpGet]
        public ActionResult Add()
        {
            
        }

    }
}
